import request from '@/utils/request'

const api_name = '/aclservice/permission'

export default {
  //获取所有菜单
  getNestedTreeList() {
    return request({
      url: `${api_name}`,
      method: 'get'
    })
  },
  //根据id删除菜单
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: "delete"
    })
  },
  //保存一个菜单
  saveLevelOne(menu) {
    return request({
      url: `${api_name}/save`,
      method: "post",
      data: menu
    })
  },
  //更新菜单
  update(menu) {
    return request({
      url: `${api_name}/update`,
      method: "put",
      data: menu
    })
  },
  //根据角色获取菜单权限
  toAssign(roleId) {
    return request({
      url: `/aclservice/role/getRoleBindPermission/${roleId}`,
      method: 'get'
    })
  },
  //更新角色匹配菜单权限
  doAssign(roleId, permissionIds) {
    return request({
      url: `/aclservice/role/roleBindPermission/${roleId}`,
      method: "post",
      data: permissionIds
    })
  },
  addRoutes(routes){
    return request({
      url:'/aclservice/permission/addRouter',
      method:'post',
      data:routes
    })
  }
}
